<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="file" id="file">
    
    <script>
         function bb(data) {
            console.log('===================',data);
        }
        file.addEventListener('change', (e) => {
            e.preventDefault();
            const file = e.target.files[0];
            console.log(file)
            const formData = new FormData();
            formData.append('name', file.name);
            formData.append('file', file);
            // 上传文件
            fetch('http://localhost:1111/upload', {
                method: 'post',
                body:formData
            }).then(res => {
                return res.blob()
            }).then(data => {
                const url = URL.createObjectURL(data);
                const a = document.createElement('a');
                a.href = url;
                document.body.appendChild(a);
                a.download = file.name+'.html'; 
                a.click();

            })
        })
        
        // const worker = new Worker('worker.js',{key:123456});
        // worker.onmessage = (e) => {
        //     console.log(e.data);
        // }
    </script>
    <script src="http://localhost:1111/get?cb=bb" alt=""></script>
</body>
</html>